<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>Closes a previously opened database connection</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mysqlnduhconnection.charsetname.html">MysqlndUhConnection::charsetName</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mysqlnduhconnection.connect.html">MysqlndUhConnection::connect</a></div>
 <div class="up"><a href="class.mysqlnduhconnection.html">MysqlndUhConnection</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="mysqlnduhconnection.close" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">MysqlndUhConnection::close</h1>
  <p class="verinfo">(PECL mysqlnd-uh &gt;= 1.0.0-alpha)</p><p class="refpurpose"><span class="refname">MysqlndUhConnection::close</span> &mdash; <span class="dc-title">Closes a previously opened database connection</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-mysqlnduhconnection.close-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="modifier">public</span> <span class="type">bool</span> <span class="methodname"><strong>MysqlndUhConnection::close</strong></span>
    ( <span class="methodparam"><span class="type"><span class="type mysqlnd_connection">mysqlnd_connection</span></span> <code class="parameter">$connection</code></span>
   , <span class="methodparam"><span class="type">int</span> <code class="parameter">$close_type</code></span>
   )</div>

  <p class="para rdfs-comment">
   Closes a previously opened database connection.
  </p>
  <blockquote class="note"><p><strong class="note">Note</strong>: 
   <p class="para">
    Failing to call the parent implementation may cause memory leaks or
    crash PHP. This is not considered a bug. Please, keep in mind that
    the <em>mysqlnd</em> library functions have never been designed
    to be exposed to the user space.
   </p>
  </p></blockquote>
 </div>


 <div class="refsect1 parameters" id="refsect1-mysqlnduhconnection.close-parameters">
  <h3 class="title">参数</h3>
  <dl>

   
    <dt>
<em><code class="parameter">connection</code></em></dt>

    <dd>

     <p class="para">
      The connection to be closed. Do not modify!
     </p>
    </dd>

   
   
    <dt>
<em><code class="parameter">close_type</code></em></dt>

    <dd>

     <p class="para">
      Why the connection is to be closed. The value
      of <em><code class="parameter">close_type</code></em> is one of
      <strong><code>MYSQLND_UH_MYSQLND_CLOSE_EXPLICIT</code></strong>,
      <strong><code>MYSQLND_UH_MYSQLND_CLOSE_IMPLICIT</code></strong>,
      <strong><code>MYSQLND_UH_MYSQLND_CLOSE_DISCONNECTED</code></strong> or
       <strong><code>MYSQLND_UH_MYSQLND_CLOSE_LAST</code></strong>. The
       latter should never be seen, unless the default
       behaviour of the <em>mysqlnd</em> library
       has been changed by a plugin.
     </p>
    </dd>

   
  </dl>

 </div>


 <div class="refsect1 returnvalues" id="refsect1-mysqlnduhconnection.close-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   Returns <strong><code>TRUE</code></strong> on success.
   Otherwise, returns <strong><code>FALSE</code></strong>
  </p>
 </div>


 <div class="refsect1 examples" id="refsect1-mysqlnduhconnection.close-examples">
  <h3 class="title">范例</h3>
  <p class="para">
   <div class="example" id="example-1851">
    <p><strong>Example #1 <span class="function"><strong>MysqlndUhConnection::close()</strong></span> example</strong></p>
        <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /></span><span style="color: #007700">function&nbsp;</span><span style="color: #0000BB">close_type_to_string</span><span style="color: #007700">(</span><span style="color: #0000BB">$close_type</span><span style="color: #007700">)&nbsp;{<br />&nbsp;</span><span style="color: #0000BB">$mapping&nbsp;</span><span style="color: #007700">=&nbsp;array(<br />&nbsp;&nbsp;</span><span style="color: #0000BB">MYSQLND_UH_MYSQLND_CLOSE_DISCONNECTED&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"MYSQLND_UH_MYSQLND_CLOSE_DISCONNECTED"</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #0000BB">MYSQLND_UH_MYSQLND_CLOSE_EXPLICIT&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"MYSQLND_UH_MYSQLND_CLOSE_EXPLICIT"</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #0000BB">MYSQLND_UH_MYSQLND_CLOSE_IMPLICIT&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"MYSQLND_UH_MYSQLND_CLOSE_IMPLICIT"</span><span style="color: #007700">,<br />&nbsp;&nbsp;</span><span style="color: #0000BB">MYSQLND_UH_MYSQLND_CLOSE_LAST&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"MYSQLND_UH_MYSQLND_CLOSE_IMPLICIT"<br />&nbsp;</span><span style="color: #007700">);<br />&nbsp;return&nbsp;(isset(</span><span style="color: #0000BB">$mapping</span><span style="color: #007700">[</span><span style="color: #0000BB">$close_type</span><span style="color: #007700">]))&nbsp;?&nbsp;</span><span style="color: #0000BB">$mapping</span><span style="color: #007700">[</span><span style="color: #0000BB">$close_type</span><span style="color: #007700">]&nbsp;:&nbsp;</span><span style="color: #DD0000">'unknown'</span><span style="color: #007700">;<br />}<br /><br />class&nbsp;</span><span style="color: #0000BB">proxy&nbsp;</span><span style="color: #007700">extends&nbsp;</span><span style="color: #0000BB">MysqlndUhConnection&nbsp;</span><span style="color: #007700">{<br />&nbsp;&nbsp;public&nbsp;function&nbsp;</span><span style="color: #0000BB">close</span><span style="color: #007700">(</span><span style="color: #0000BB">$res</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$close_type</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"%s(%s)\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">__METHOD__</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">var_export</span><span style="color: #007700">(</span><span style="color: #0000BB">func_get_args</span><span style="color: #007700">(),&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">));<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"close_type&nbsp;=&nbsp;%s\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">close_type_to_string</span><span style="color: #007700">(</span><span style="color: #0000BB">$close_type</span><span style="color: #007700">));<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #FF8000">/*&nbsp;WARNING:&nbsp;you&nbsp;must&nbsp;call&nbsp;the&nbsp;parent&nbsp;*/<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">$ret&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">parent</span><span style="color: #007700">::</span><span style="color: #0000BB">close</span><span style="color: #007700">(</span><span style="color: #0000BB">$res</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">$close_type</span><span style="color: #007700">);<br />&nbsp;&nbsp;&nbsp;</span><span style="color: #0000BB">printf</span><span style="color: #007700">(</span><span style="color: #DD0000">"%s&nbsp;returns&nbsp;%s\n"</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">__METHOD__</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">var_export</span><span style="color: #007700">(</span><span style="color: #0000BB">$ret</span><span style="color: #007700">,&nbsp;</span><span style="color: #0000BB">true</span><span style="color: #007700">));<br />&nbsp;&nbsp;&nbsp;return&nbsp;</span><span style="color: #0000BB">$ret</span><span style="color: #007700">;<br />&nbsp;}<br />}<br /></span><span style="color: #0000BB">mysqlnd_uh_set_connection_proxy</span><span style="color: #007700">(new&nbsp;</span><span style="color: #0000BB">proxy</span><span style="color: #007700">());<br /><br /></span><span style="color: #0000BB">$mysqli&nbsp;</span><span style="color: #007700">=&nbsp;new&nbsp;</span><span style="color: #0000BB">mysqli</span><span style="color: #007700">(</span><span style="color: #DD0000">"localhost"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"root"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">""</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"test"</span><span style="color: #007700">);<br /></span><span style="color: #0000BB">$mysqli</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">close</span><span style="color: #007700">();<br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
proxy::close(array (
  0 =&gt; NULL,
  1 =&gt; 0,
))
close_type = MYSQLND_UH_MYSQLND_CLOSE_EXPLICIT
proxy::close returns true
</pre></div>
    </div>
   </div>
  </p>
 </div>


 <div class="refsect1 seealso" id="refsect1-mysqlnduhconnection.close-seealso">
  <h3 class="title">参见</h3>
  <p class="para">
   <ul class="simplelist">
    <li class="member">
     <span class="function"><a href="function.mysqlnd-uh-set-connection-proxy.html" class="function" rel="rdfs-seeAlso">mysqlnd_uh_set_connection_proxy()</a> - Installs a proxy for mysqlnd connections</span>
    </li>
    <li class="member">
     <span class="function"><a href="mysqli.close.html" class="function" rel="rdfs-seeAlso">mysqli_close()</a> - 关闭先前打开的数据库连接</span>
    </li>
    <li class="member">
     <span class="function"><a href="function.mysql-close.html" class="function" rel="rdfs-seeAlso">mysql_close()</a> - 关闭 MySQL 连接</span>
    </li>
   </ul>
  </p>
 </div>


</div><hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="mysqlnduhconnection.charsetname.html">MysqlndUhConnection::charsetName</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="mysqlnduhconnection.connect.html">MysqlndUhConnection::connect</a></div>
 <div class="up"><a href="class.mysqlnduhconnection.html">MysqlndUhConnection</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
